﻿using System;
using viNews.Classes;
using viNews.Controllers;
using visinia.SmartEngine;

public partial class Admin_Pages_viNews_News_ManageNews : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void GridViewNEWS_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {        
        if (e.CommandName == "DeleteNews")
        {
            int id = Convert.ToInt32(e.CommandArgument);            
            NewsController.DeleteNews(id);
            Response.Redirect(Request.RawUrl);
        }
    }

    public string GetCategory(int CategoryId)
    {
        Category category = CategoryController.GetCategory(CategoryId);
        if (category != null)
        {
            Category parent = CategoryController.GetParentCategory(category.CategoryId);
            if (parent != null)
            {
                return parent.Name + "/" + category.Name;
            }
            else
            {
                return category.Name;
            }
        }
        else
            return null;
    }

    public string GetImage(bool Publish)
    {
        if (Publish)
            return "Images/Published.png";
        return "Images/NonPublished.gif";
    }

    public string GetLink(int newsid)
    {
        return SystemMenu.CallPage("viNews", "EditNews", "NewsId", newsid.ToString());
    }
    protected void ADD_NEWS_Click(object sender, EventArgs e)
    {
        Response.Redirect(SystemMenu.CallPage("viNews", "AddNews"));
    }
}

